class AttractionModel {
  final String id;
  final String name;
  final String nameEn;
  final String description;
  final String destinationId;
  final String
  category; // 景点类型：historical, natural, cultural, entertainment, etc.
  final double latitude;
  final double longitude;
  final String address;
  final List<String> images;
  final String coverImage;
  final double rating;
  final int reviewCount;
  final List<String> tags;
  final Map<String, String> openingHours; // {"monday": "9:00-17:00", ...}
  final Map<String, dynamic> ticketInfo; // 门票信息
  final int visitDuration; // 建议游玩时长（分钟）
  final String difficulty; // 游玩难度：easy, medium, hard
  final List<String> facilities; // 设施：wifi, parking, restaurant, etc.
  final bool isAccessible; // 是否无障碍
  final String phone;
  final String website;
  final DateTime createdAt;
  final DateTime updatedAt;

  AttractionModel({
    required this.id,
    required this.name,
    required this.nameEn,
    required this.description,
    required this.destinationId,
    required this.category,
    required this.latitude,
    required this.longitude,
    required this.address,
    required this.images,
    required this.coverImage,
    required this.rating,
    required this.reviewCount,
    required this.tags,
    required this.openingHours,
    required this.ticketInfo,
    required this.visitDuration,
    required this.difficulty,
    required this.facilities,
    required this.isAccessible,
    required this.phone,
    required this.website,
    required this.createdAt,
    required this.updatedAt,
  });

  factory AttractionModel.fromJson(Map<String, dynamic> json) {
    return AttractionModel(
      id: json['_id'] ?? json['id'] ?? '',
      name: json['name'] ?? '',
      nameEn: json['nameEn'] ?? '',
      description: json['description'] ?? '',
      destinationId: json['destinationId'] ?? '',
      category: json['category'] ?? '',
      latitude: (json['latitude'] ?? 0.0).toDouble(),
      longitude: (json['longitude'] ?? 0.0).toDouble(),
      address: json['address'] ?? '',
      images: List<String>.from(json['images'] ?? []),
      coverImage: json['coverImage'] ?? '',
      rating: (json['rating'] ?? 0.0).toDouble(),
      reviewCount: json['reviewCount'] ?? 0,
      tags: List<String>.from(json['tags'] ?? []),
      openingHours: Map<String, String>.from(json['openingHours'] ?? {}),
      ticketInfo: Map<String, dynamic>.from(json['ticketInfo'] ?? {}),
      visitDuration: json['visitDuration'] ?? 120,
      difficulty: json['difficulty'] ?? 'easy',
      facilities: List<String>.from(json['facilities'] ?? []),
      isAccessible: json['isAccessible'] ?? false,
      phone: json['phone'] ?? '',
      website: json['website'] ?? '',
      createdAt:
          json['createdAt'] != null
              ? DateTime.parse(json['createdAt'])
              : DateTime.now(),
      updatedAt:
          json['updatedAt'] != null
              ? DateTime.parse(json['updatedAt'])
              : DateTime.now(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'nameEn': nameEn,
      'description': description,
      'destinationId': destinationId,
      'category': category,
      'latitude': latitude,
      'longitude': longitude,
      'address': address,
      'images': images,
      'coverImage': coverImage,
      'rating': rating,
      'reviewCount': reviewCount,
      'tags': tags,
      'openingHours': openingHours,
      'ticketInfo': ticketInfo,
      'visitDuration': visitDuration,
      'difficulty': difficulty,
      'facilities': facilities,
      'isAccessible': isAccessible,
      'phone': phone,
      'website': website,
      'createdAt': createdAt.toIso8601String(),
      'updatedAt': updatedAt.toIso8601String(),
    };
  }
}
